import request from "@/utils/request";

const baseUrl = '/menu';

export function getList(query?: SysMenuQuery) {
    return request({
        url: `${baseUrl}/search`,
        method: 'POST',
        data: query,
    });
}

export function deleteById(id: string) {
    return request({
        url: `${baseUrl}/${id}`,
        method: 'DELETE',
    });
}

export function getMenuSelect() {
    return request({
        url: `${baseUrl}/select`,
        method: 'GET',
    });
}

export function add(data: SysMenuType) {
    return request({
        url: `${baseUrl}`,
        method: 'POST',
        data,
    });
}

export function update(data: SysMenuType) {
    return request({
        url: `${baseUrl}`,
        method: 'PUT',
        data,
    });
}

// 查询登录的用户信息及所拥有的菜单按钮权限数据
export function getMenuUser() {
    return request({
        url: `${baseUrl}/user`,
        method: 'GET'
    });
}

// 查询登录的用户所拥有的菜单数据
export function getCurrMenus(roleIds: string) {
    return request({
        url: `${baseUrl}/getCurrMenus`,
        method: 'GET',
        params: { roleIds }
    });
}
